/**
 * Created by user on 2018/5/21.
 */
import { MaterialActionType } from '../actions/materialAction'

const material_state = {
  show: false,
  images: [],
  index: 0,
  showVideo: false,
  loading: false
}

const MaterialState = (state = material_state, action) => {
  switch (action.type) {
    case MaterialActionType.toggle_loading:
      return Object.assign({}, state, {
        loading: action.loading
      })
    case MaterialActionType.toggle_material_show:
      return Object.assign({}, state, {
        show: action.show
      })
    case MaterialActionType.init_swiper:
      return Object.assign({}, state, {
        images: action.images,
        index: action.index
      })
    case MaterialActionType.change_index:
      return Object.assign({}, state, {
        index: action.index
      })
    case MaterialActionType.change_video_mask:
      return Object.assign({}, state, {
        showVideo: action.show
      })
    default:
      return state
  }
}
MaterialState._default_state = material_state
export default MaterialState
